package com.order_system.controller;


import com.order_system.constants.Code;
import com.order_system.entity.Purchase;
import com.order_system.entity.ResModel;
import com.order_system.service.PurchaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 李阳
 * @since 2023-01-06
 */
@RestController
@RequestMapping("/api/purchase")
public class PurchaseController {

    @Autowired
    private PurchaseService purchaseService;

    /**
     * 添加采购商品
     * @param purchase 采购商品
     * @return
     */
    @PostMapping(value = "/save",produces = "application/json")
    public ResModel save(@RequestBody Purchase purchase){
        return ResModel.success(Code.SUCCESS,purchaseService.save(purchase));
    }

    /**
     * 查询采购商品列表
     * @return
     */
    @GetMapping("/list")
    public ResModel list(){
        return purchaseService.getList();
    }

}

